home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / ASSEMBLE / H235A.ZIP / ASM_0_M.ZIP / ATTPOINT.ASM < prev    next >
Assembly Source File  |  1987-07-31  |  8KB  |  240 lines

  1.  
  2.  
  3.  
  4. ;            TURBO PASCAL CALLABLE
  5. ;           AT&T 640*400 POINT SETTING ROUTINE
  6. ;
  7. ;Author: Rob Alexander
  8. ;     13217 Emily Lane
  9. ;     Dallas,Tx 75240
  10. ;     214-644-9359
  11. ;
  12. ;Comments:  I have heavily documented what I have learned about the
  13. ;        AT&T 6300 640*400 graphics and handling the Turbo Pascal
  14. ;        assembly language "interface"; parameter passing etc...
  15. ;        I did this primarily as a reference for future work so
  16. ;           I wouldn't have to fight the same battle twice. I hope
  17. ;        others may benefit also.
  18. ;
  19. ;********************** STACK MEMORY MAP **************************
  20. ;
  21. ; PROCEDURE Point( X,Y:INTEGER;VAR Test: INTEGER) sets up the stack as
  22. ; follows
  23. ;  < Top of Stack before Call        >            {Increasing addr}
  24. ;  < X value               (2 bytes)>  {SP+8}    {BP+10}    ^
  25. ;  < Y value               (2 bytes)>  {SP+6}    {BP+8}    *
  26. ;  < Test value Segment addr   (2 bytes)>            *
  27. ;  < Test value Offset    addr   (2 bytes)>  {SP+2}    {BP+4}    *
  28. ;  < Return Address           (2 bytes)>  {SP}      {BP+2}    *
  29. ;  < BP register           (2 bytes)>  {SP-2}    {BP}    *
  30. ;
  31. ;*********************************************************************
  32. ;
  33. ; Define Point Procedure
  34. ;
  35. ; CONSTANTS DEFINITION
  36. ;
  37.     GraphSeg = 0B800H           ;Graphics Memory Segment Address
  38. ;
  39. CODE   SEGMENT
  40.        Assume CS:Code
  41. ;
  42. Point  PROC  NEAR
  43.        push  bp              ;Save Base pointer
  44.        mov bp,sp             ;Initialize Base pointer
  45. ;      les di,[bp+4]             ;For test value passing
  46. ;****************** 8k BLOCK CALCULATION*****************************
  47. ;
  48. ;DISCUSSION: In 640 by 400 mode, the 32K graphics memory is divided into
  49. ;      four 8000 byte long blocks. Each block contains the pixel
  50. ;      definitions for 100 rows. According to the AT&T system programmers
  51. ;      guide, the memory map looks like:
  52. ;
  53. ;     ----------------      B800:7F3F
  54. ;    * Rows          *
  55. ;    * 3,7,11..399    *
  56. ;    ------------------   B800:6000
  57. ;    ------------------   B800:5F3F
  58. ;    * Rows          *
  59. ;    * 2,6,10,..398   *
  60. ;    ------------------   B800:4000
  61. ;    ------------------   B800:3F3F
  62. ;    * Rows          *
  63. ;    * 1,5,9..397     *
  64. ;    ------------------   B800:2000  {there are 192 unused bytes between
  65. ;    ------------------   B800:1F3F   blocks}
  66. ;    * Rows          *
  67. ;    * 0,4,8,..396    *
  68. ;    ------------------   B800:0000
  69. ;
  70. ;
  71. ; CALCULATION METHOD:
  72. ;
  73. ;  1) Read Y (row number) passed from Turbo Pascal
  74. ;  2) Determine remainder of Y/4. This is accomplished by masking upper 14
  75. ;     bits of Y value so that
  76. ;      LSB+1   LSB      Action
  77. ;    0    0     Y value divisible by 4. Pixel in first 8 k block.
  78. ;    0    1     Remainder of 1/4. Pixel in second 8K block
  79. ;    1    0     Remainder of 1/2. Pixel in third 8K block
  80. ;    1    1     Remainder of 3/4. Pixel in fourth 8K block.
  81. ;
  82. ;  3) Multiply remainder by 2000H to obtain correct 8K page offset
  83. ;
  84. ;  CONSTANTS DEFINITION
  85. ;
  86.      OffsetMult =  20H              ;8K offset
  87.      Ymask    =  03H              ;Row number mask
  88.      OffsetShift = 08              ;shift count for result of offset calc.
  89. ;
  90. ; Algorithm: The offset calculation is done as
  91. ;
  92. ;    a)   ax<----8K_OffsetMult
  93. ;    b)   bx<----Row number
  94. ;    c)   bx<----Row number (AND) Ymask   {Result is 8K_Block#}
  95. ;    d)   ax<----20H*Remainder    {want result in AX register}
  96. ;    e)   ax<----20H*256    {Perform shift to obtain proper bit level
  97. ;
  98. ;    Perform Calculation
  99. ;
  100.     mov ax,OffsetMult         ;Offset multiplier
  101.     mov bx,[bp+8]             ;Y value passed from Turbo
  102.     mov cl,OffsetShift         ;Load CL register with shift count
  103.     and bl,Ymask             ;mask off higher order bits
  104.     mul bl                 ;Find Bank offset
  105.     shl ax,cl             ;Bring offset to correct bit level
  106.     mov dx,ax             ;Save 8K_BlockOffset in DX
  107. ;
  108. ; ************************ Row Block Calculation ***********************
  109. ;
  110. ; Discussion: According to Systems Programmer guide, each 8K block contains
  111. ;          the pixel values for 100 rows as follows;
  112. ;
  113. ;                     Row Number    Offset
  114. ;   /byte 0/byte 1/......./byte 79/       99          8K_BlockOffset+99*80
  115. ;   /byte 0/byte 1/......./byte 79/       98          8K_BlockOffset+98*80
  116. ;
  117. ;
  118. ;   /byte 0/byte 1/......./byte 79/        1          8K_BlockOffset+1*80
  119. ;   /byte 0/byte 1/......./byte 79/        0          8K_Block#+0*80
  120. ;
  121. ; CALCULATION METHOD:
  122. ;
  123. ;   1)    Read Y {row number} from stack
  124. ;   2)    Row_Block# = Row Number/4
  125. ;   3)    Row_Offset=Row_Block# * 80
  126. ;   4)    Offset = 8K_Block Offset + Row_Offset
  127. ;
  128. ; ALGORITHM
  129. ;   a)    ax<---- Row_OffsetMult
  130. ;   b)    bx<---- Y value {Row number} passed from Turbo Pascal
  131. ;   c)    cl<---- Row_RmdrShift
  132. ;   d)    bx<---- Row number/4
  133. ;   e)    ax<---- (Row number/4)*80
  134. ;   f)    dx<---- 8K_BlockOffset + Row_BlockOffset
  135. ;
  136. ;  CONSTANTS DEFINITION
  137. ;
  138.     Row_RmdrShift  = 80
  139.     Row_BlockShift = 2
  140. ;
  141. ;  Perform Calculation
  142. ;
  143.     mov al,Row_RmdrShift         ;
  144.     mov bx,[BP+8]             ;Read Y value passed from Turbo Pascal
  145.     mov cl,Row_BlockShift         ;
  146.     shr bx,cl             ;Divide Row number by 4
  147.     mul bl                 ;Find Row_Offset
  148.     add dx,ax             ;Calculate offset
  149. ;
  150. ;*********************** COLUMN OFFSET CALCULATION ***********************
  151. ;
  152. ; Discussion: The pixel values for each row {640 pixels} are stored in
  153. ;          80 bytes. {1 bit per pixel} as shown below
  154. ;     /byte 0/byte 1/......./byte n/...../byte 79/
  155. ;      ^              ^
  156. ;      |.. Row base address   |..Column Address/8
  157. ;
  158. ; CALCULATION METHOD:
  159. ;
  160. ;   1) Column_byte_Addr=X value/8
  161. ;
  162. ;  CONSTANTS DEFINITION
  163. ;
  164.      Column_Shift = 3
  165. ;
  166. ;  PERFORM CALCULATION
  167. ;
  168.      mov ax,[bp+10]          ;Read X value passed from Turbo Pascal
  169.      mov bx,ax              ;Save X value for next calculation stage
  170.      mov cl,Column_Shift      ;Initialize Shift count
  171.      shr ax,cl              ;Divide X value by 8
  172.      add dx,ax              ;Save Offset
  173. ;
  174. ;************************ PIXEL MASK GENERATION **************************
  175. ;
  176. ;  Discussion: Finally, we're ready to set the pixel. The pixel bit map
  177. ;           looks like
  178. ;
  179. ;          /bit 7/ bit 6/......../bit 1/bit 0/
  180. ;      pixel 0...^                ^..pixel 7
  181. ;
  182. ;        {the bit map is the reverse from what you would expect}
  183. ;
  184. ;  CALCULATION METHOD
  185. ;
  186. ;   1) Pixel No<----- Remainder{Column address,8}
  187. ;   2) Pixel Mask<---- 1 shifted by pixel number
  188. ;   3) Reg <---- Current Pixel Byte
  189. ;   4) Updated Pixel Byte<----Pixel Mask (OR) Pixel Settings
  190. ;   5) Mem<----- Pixel Byte
  191. ;
  192. ;   CONSTANTS DEFINITION
  193. ;
  194.      Const= 128
  195.      Pixel_Rmdr_Mask = 0007
  196. ;
  197. ;  PERFORM CALCULATION
  198. ;
  199.     mov ax,GraphSeg
  200.     mov es,ax
  201.     mov di,dx
  202.     and bl,Pixel_Rmdr_Mask            ;Find remainder of Col#/8
  203.     mov cl,bl                ;Generate Pixel Mask
  204.     mov bx,Const                ;
  205.     shr bx,cl
  206.     mov al,byte ptr es:[di]         ;Read Current Pixel Setting
  207.     or al,bl                ;Set pixel
  208.     mov byte ptr es:[di],al
  209. ;    mov word ptr es:[di],bx
  210. ;
  211. ;    restore registers and return to Turbo
  212. ;
  213.     mov sp,bp
  214.     pop bp
  215. ;************************************************************************
  216. ;************************************************************************
  217. ;************************************************************************
  218. ;********* ATTENTION, ATTENTION, ATTENTION, ATTENTION *******************
  219. ;********* In order for External procedure to work,   *******************
  220. ;********* you must figure out how many parameters    *******************
  221. ;********* were passed on stack {in bytes} and          *******************
  222. ;********* and include that number in return statemt. *******************
  223. ;********* In the case of this program;           *******************
  224. ;*********                          *******************
  225. ;*********   X co-ordinate value = 2 bytes          *******************
  226. ;*********   Y co-ordinate value = 2 bytes          *******************
  227. ;*********    Test value address = 4 bytes          *******************
  228. ;*********               -------          *******************
  229. ;*********               8 bytes          *******************
  230. ;*********                          *******************
  231. ;********* It took me a hell of a long time to figure *******************
  232. ;********* that out.- Rob Alexander              *******************
  233. ;************************************************************************
  234. ;************************************************************************
  235. ;************************************************************************
  236.     ret  08H                 ;Release Stack used for Call
  237. Point    ENDP
  238. Code    ENDS
  239. END
  240.